#!/usr/bin/env python
# -*- coding: utf-8 -*-

import webapp2
import functools

from android_handler import AndroidHandler
# from model_message import Message
from model_KG import Kindergarten
from google.appengine.api import users
import web_handler

from apiclient.discovery import build
from oauth2client.appengine import OAuth2Decorator
from google.appengine.api import oauth

import httplib2
import logging
import os

from apiclient import discovery
from oauth2client import appengine
from oauth2client import client
from google.appengine.api import memcache

import settings

import json

global decorator
decorator = OAuth2Decorator(client_id   = settings.CLIENT_ID,
                            client_secret=settings.CLIENT_SECRET,
                            scope       =settings.SCOPE)

http = httplib2.Http(memcache)
service = discovery.build('oauth2', 'v2')


class loginPage(webapp2.RequestHandler):
    @decorator.oauth_required
    def get(self):
        self.redirect('/')

app = webapp2.WSGIApplication([
                              ('/',                     web_handler.mainWeb),
                              ('/login',                loginPage),
                              ('/help',                 web_handler.help),
                              ('/home',                 web_handler.displayAtt),
                              ('/welcome',              web_handler.welcomePage),
                              ('/editAtt',              web_handler.editAtt),
                              ('/updateParents',        web_handler.updateParents),
                              ('/childInfo',            web_handler.childInfo),
                              ('/editChild/([^/]+)?',   web_handler.editChild),
                              ('/editChild',            web_handler.editChild),
                              ('/editKG',               web_handler.editKG),
                              ('/messages',             web_handler.displayMessages),
                              ('/privateMessages',      web_handler.privateMessages),
                              ('/childMessages',        web_handler.childMessages),
                              ('/addMessage',           web_handler.addMessage),
                              ('/contactList',          web_handler.contactList),
                              ('/addChild',             web_handler.addChild),
                              ('/messageDelete/([^/]+)?',   web_handler.messageDelete),
                              ('/monthlyReports',       web_handler.monthlyReports),
                              ('/report',               web_handler.report),
                              ('/addKG',                web_handler.addKG),
                              ('/android/([^/]+)?',     AndroidHandler),
                              (decorator.callback_path, decorator.callback_handler())
                              ], debug=True)



